<html>
<head>
	<script type="text/javascript">
		var aJaxURL		= "server-side/operations/transaction.action.php";
		var aJaxURL1	= "server-side/operations/transaction.action1.php";
		var aJaxURL1_1	= "server-side/operations/transaction.action1_1.php";
		var aJaxURL2	= "server-side/operations/transaction.action2.php";	//server side folder url
		var seoyURL = "server-side/seoy/seoy.action.php";			//server side folder url
		var tName	= "example";											//table name
		var fname	= "add-edit-form";
		var tbName		= "tabs";										//form name
		var tab=0;   	
		$(document).ready(function () {
			GetTabs(tbName); 
			LoadTable();
			
			/* Add Button ID, Delete Button ID */
			GetButtons("", "delete_button");			
			SetEvents("", "delete_button", "check-all", "example", "", aJaxURL);
					
		});
		$(document).on("tabsactivate", "#tabs", function() {
        	tab = GetSelectedTab(tbName);
        	if (tab == 0) {
        		LoadTable();
        		GetButtons("", "delete_button");			
    			SetEvents("", "delete_button", "check-all", "example", "", aJaxURL);
         	}else if(tab == 1){
         		LoadTable1();
         		GetButtons("", "delete_button1");			
    			SetEvents("", "delete_button1", "check-all", "example11111", fname, aJaxURL1);
         	}
         	else if(tab == 2){
         		LoadTable2();
         	}
        });
		
		function LoadTable(){
			/* Table ID, aJaxURL, Action, Colum Number, Custom Request, Hidden Colum, Menu Array */
			GetDataTable(tName, aJaxURL, "get_list", 3, "", 0, "", 1,"desc");
		}
		function LoadTable1(){
			/* Table ID, aJaxURL, Action, Colum Number, Custom Request, Hidden Colum, Menu Array */
			GetDataTable("example11111", aJaxURL1, "get_list", 4, "", 0, "", 1,"desc");
		}
		function LoadTable2(){
			/* Table ID, aJaxURL, Action, Colum Number, Custom Request, Hidden Colum, Menu Array */
			GetDataTable("example2", aJaxURL2, "get_list", 4, "", 0, "", 1,"desc");
		}
		function LoadTable1_1(ggg){
			var ggg = $("#tarns_hid_id").val();
			/* Table ID, aJaxURL, Action, Colum Number, Custom Request, Hidden Colum, Menu Array */
			 GetDataTable("example11_1", aJaxURL1_1, "get_list", 7, "tarns_hid_id=" + ggg, 0, "", 1,"desc");
			 GetButtons("", "delete_button1_1");
			 SetEvents("", "delete_button1_1", "check-all", "example11_1", "add-edit-form1", aJaxURL1_1);
		}

function LoadDialog(fname){
	
	switch(fname){
		case "add-edit-form":
			var buttons = {	
			       "save": {
			            text: "შენახვა",
			            id: "save-dialog"
			        }, 
				 "cancel": {
			            text: "დახურვა",
			            id: "cancel-dialog",
			            click: function () {
			            	$(this).dialog("close");
			            }
		        	}
		        	
			    };
			var rid = $("#tarns_hid_id").val();
		    if(tab==1){
		    GetDialog(fname, 1100, "auto",buttons );
		    				
		    GetDataTable("example11_1", aJaxURL1_1, "get_list", 7, "tarns_hid_id=" + rid, 0, "", 1,"desc");
		    GetButtons("", "delete_button1_1");
		    SetEvents("", "delete_button1_1", "check-all", "example11_1", "add-edit-form1", aJaxURL1_1);
		    } 
		  break;
		case "add-edit-form1":
			var buttons = {	
			       "save": {
			            text: "შენახვა",
			            id: "save-dialog1"
			        }, 
				 "cancel": {
			            text: "დახურვა",
			            id: "cancel-dialog",
			            click: function () {
			            	$(this).dialog("close");
			            }
		        	}
		        	
			    };
			GetDialog("add-edit-form1", 300, "auto",buttons );
			break;
		}
	}
$(document).on("click", "#save-dialog", function () {
	LoadTable1();
	CloseDialog("add-edit-form");
	
});
$(document).on("click", "#save-dialog1", function () {
   
		param = new Object();
    	
        //Action
    	param.act		= "count_change";	

    	param.detail_id		 = $("#detail_id").val();    	    
		param.old_quantity	 = $("#product_quantity").val();
	    param.new_quantity	 = $("#prod_new_count").val();
	    param.production_id	 = $("#production_id").val();
	    param.cost			 = $("#cost").val();
	    param.transaction_id = $("#transaction_id").val();
	    
	    
	    $.ajax({
	        url: aJaxURL1_1,
		    data: param,
	        success: function(data) {
				if(typeof(data.error) != "undefined")
				{
					if(data.error != "")
					{
						alert(data.error);
					}else{
						LoadTable1_1();
						CloseDialog("add-edit-form1");
					}
				}
		    }
	    });	
});
		
    </script>
</head>

<body>
   <div id="tabs" style="width: 99%; margin: 0 auto; min-height: 768px; margin-top: 17px;">
   
    	<ul>
			<li><a href="#tab-0">შენახული</a></li>
			<li><a href="#tab-1">დასრულებული</a></li>
			<li><a href="#tab-2">გაუქმებული</a></li>
		</ul>
	
		<div style="margin-top: 13px;" id="tab-0">
            	<h2 align="center">ტრანზაქციები</h2>
            	 <div id="button_area">
        			<button id="delete_button">გაუქმება</button>
        		</div>
                <table class="display" id="example">
                    <thead>
                        <tr id="datatable_header">
                            <th>ID</th>
                            <th style="width: 100%;">თარიღი</th>
                           <th class="min">სტატუსი</th>
                            <th class="check">#</th>
                        </tr>
                    </thead>
                    <thead>
                        <tr class="search_header">
                            <th class="colum_hidden">
                            	<input type="text" name="search_id" class="search_init" />
                            </th>
                            <th>
                                <input type="text" name="search_browser" value="ფილტრი" class="search_init" />
                            </th>
                           <th>
                                <input type="text" name="search_browser" value="ფილტრი" class="search_init" />
                            </th>
                            <th>
                            	<input type="checkbox" name="check-all" id="check-all">
                            </th>
                        </tr>
                    </thead>
                </table>
            </div>
          <div style="margin-top: 13px;" id="tab-1">
            	<h2 align="center">ტრანზაქციები</h2>
            	 <div id="button_area">
        			<button id="delete_button1">გაუქმება</button>
        		</div>
                <table class="display" id="example11111">
                    <thead>
                        <tr id="datatable_header">
                            <th>ID</th>
                            <th style="width: 100%;">თარიღი</th>
                            <th class="min">ჯამური თანხა</th>
                            <th class="min">სტატუსი</th>
                            <th class="check">#</th>
                        </tr>
                    </thead>
                    <thead>
                        <tr class="search_header">
                            <th class="colum_hidden">
                            	<input type="text" name="search_id" class="search_init" />
                            </th>
                            <th>
                                <input type="text" name="search_browser" value="ფილტრი" class="search_init" />
                            </th>
                            <th>
                                <input type="text" name="search_browser" value="ფილტრი" class="search_init" />
                            </th>
                            <th>
                                <input type="text" name="search_browser" value="ფილტრი" class="search_init" />
                            </th>
                            <th>
                            	<input type="checkbox" name="check-all" id="check-all">
                            </th>
                        </tr>
                    </thead>
                </table>
            </div>
            <div style="margin-top: 13px;" id="tab-2">
            	<h2 align="center">ტრანზაქციები</h2>
                <table class="display" id="example2">
                    <thead>
                        <tr id="datatable_header">
                            <th>ID</th>
                            <th style="width: 100%;">თარიღი</th>
                            <th class="min">ჯამური თანხა</th>
                            <th class="min">სტატუსი</th>
                         </tr>
                    </thead>
                    <thead>
                        <tr class="search_header">
                            <th class="colum_hidden">
                            	<input type="text" name="search_id" class="search_init" />
                            </th>
                            <th>
                                <input type="text" name="search_browser" value="ფილტრი" class="search_init" />
                            </th>
                            <th>
                                <input type="text" name="search_browser" value="ფილტრი" class="search_init" />
                            </th>
                            <th>
                                <input type="text" name="search_browser" value="ფილტრი" class="search_init" />
                            </th>
                        
                        </tr>
                    </thead>
                </table>
            </div>  
        </div>
          <!-- jQuery Dialog -->
	    <div id="add-edit-form" class="form-dialog" title="გაყიდულის გაუქმება">
	    </div>
	     <div id="add-edit-form1" class="form-dialog" title="გაყიდულის რაოდენობა">
	    </div>
</body>
</html>